/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.helpdesk.dao;

import com.helpdesk.entidades.HdAsesor;
import com.helpdesk.entidades.HdUsuarios;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Manuel
 */
@Stateless
public class HdAsesorFacade extends AbstractFacade<HdAsesor> {
    @PersistenceContext(unitName = "WebAppHelpDeskPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public HdAsesorFacade() {
        super(HdAsesor.class);
    }

    public HdAsesor BuscarIdAsesor(int User) {
        Query q =em.createNamedQuery("HdAsesor.findByCodAsesor");
        q.setParameter("codUsuario", User);
        HdAsesor Ase = null;
        try {
            Ase = (HdAsesor) q.getSingleResult();
            System.out.println("Entro");
        } catch (Exception e) {
            System.out.println("Dio error");
            Ase = new HdAsesor(0); //No se encontro ningun registro
        }
    return Ase;
    }
}
